﻿@{
    ViewBag.Title = "EditPassword";
    Layout = "~/Views/Shared/_Layout_lay_admin.cshtml";
}

<div class="layui-form layuimini-form" style="max-width:400px;">
    <div class="layui-form-item">
        <label class="layui-form-label required">旧的密码</label>
        <div class="layui-input-block">
            <input type="password" name="old_password" lay-verify="required" lay-reqtext="旧的密码不能为空" placeholder="请输入旧的密码" value="" class="layui-input" autocomplete="off">
            <tip>填写自己账号的旧的密码。</tip>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">新的密码</label>
        <div class="layui-input-block">
            <input type="password" name="new_password" lay-verify="required" lay-reqtext="新的密码不能为空" placeholder="请输入新的密码" value="" class="layui-input"  autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">新的密码</label>
        <div class="layui-input-block">
            <input type="password" name="again_password" lay-verify="required" lay-reqtext="新的密码不能为空" placeholder="请输入新的密码" value="" class="layui-input" autocomplete="off">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'miniTab'], function () {
        var form = layui.form,
            layer = layui.layer,
            miniTab = layui.miniTab;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            //var index = layer.alert(JSON.stringify(data.field), {
            //    title: '最终的提交信息'
            //}, function () {
            //    layer.close(index);
            //    miniTab.deleteCurrentByIframe();
            //});
             $.ajax({
                url: '/BaseUser/EditPassword',
                type: 'post',
                dataType: 'text',
                data: data.field,
                success: function (resp) {
                    var json = eval('(' + resp + ')');
                    if (json.Code == "m001") {
                        var index = layer.alert(json.Message, function () {
                            // 关闭弹出层
                            layer.close(index);
                            miniTab.deleteCurrentByIframe();
                        });
                    } else {
                        layer.alert(json.Message);
                    }

                    
                    //layer.alert(json.Message);
                    //reloadTable();
                },
                error: function (resp) {
                    layer.alert("对不起出错了");
                }
            });
            return false;
        });

    });
</script>